//请求封装函数
import request from "./request";

import mockRequest from "./mockRequest"; //模拟数据请求

//Home 组件
export const reqCategoryList = () => request({ url: "/product/getBaseCategoryList", method: 'get' })
export const reqBannerList = () => mockRequest({ url: "/banner", method: 'get' })
export const reqFloorList = () => mockRequest({ url: "/floor", method: 'get' })
//Search 组件请求
export const reqSearchData = (params = {}) => request({ url: "/list", method: 'post', data: params })
export const reqOrderNav = () => mockRequest({ url: "/ordernav", method: 'get' })
//GoodsDetail 组件请求
export const reqGoodsInfo = (goodsId) => request({ url: `/item/${goodsId}`, method: 'get' })
export const reqAddUpdateCar = (goodsId, goodsNum) => request({ url: `/cart/addToCart/${goodsId}/${goodsNum}`, method: 'POST' })
//ShopCart 组件请求 api/cart/cartList
export const reqShopCartList = () => request({ url: "/cart/cartList", method: 'get' })
export const reqDeleteGoods = (goodsId) => request({ url: `/cart/deleteCart/${goodsId}`, method: 'delete' })
export const reqCheckedGoods = (goodsId, isChecked) => request({ url: `/cart/checkCart/${goodsId}/${isChecked}`, method: 'get' })
//register注册组件请求 /api/user/passport/sendCode/phone
export const reqGetCode = (phone) => request({ url: `/user/passport/sendCode/${phone}`, method: 'get' })
export const reqUserRegister = (data) => request({ url: `/user/passport/register`, method: 'post', data })
//Login登录组件请求
export const reqUserLogin = (data) => request({ url: '/user/passport/login', method: 'post', data })
export const reqUserInfo = () => request({ url: '/user/passport/auth/getUserInfo', method: 'get' })
export const reqLogOut = () => request({ url: '/user/passport/logout', method: 'get' })
export const reqUserAddress = () => request({ url: '/user/userAddress/auth/findUserAddressList', method: 'get' })
export const reqOrderInfo = () => request({ url: '/order/auth/trade', method: 'get' })

export const reqSubmitOrder = (tradeNo, data) => request({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, method: 'post', data })

//Pay组件 获取提交订单支付信息
export const reqPayInfo = (orderId) => request({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' })
//Pay组件 获取订单支付状态
export const reqPayStatus = (orderId) => request({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' })
//Center组件 获取我的订单列表
export const reqMyOrderList = (page, limit) => request({ url: `/order/auth/${page}/${limit}`, method: 'get' })
